#include<stdio.h>
#include<string.h>

struct student{
    char name[21];
    int sno;
    double chinese;
    double english;
    double math;
    double sum;
};

int main()
{
	int j,i,n=0,t,flag=1;
	char b[100];
	struct student member[200];
	while (scanf("%s",member[n].name)==1)
	{
		if (strcmp(member[n].name,"exit")!=0)
		{
			scanf("%d",&member[n].sno);
			scanf("%lf",&member[n].chinese);
			scanf("%lf",&member[n].english);
			scanf("%lf",&member[n].math);
			member[n].sum=member[n].chinese+member[n].english+member[n].math;
			n++;
		}
		else
		{
			flag=0;
			break;
		}
	}
	for (i=0;i<n-1;i++)
		for (j=0;j<n-1-i;j++)
			if (member[j].sum<member[j+1].sum)
			{
				strcpy(b,member[j].name);
				strcpy(member[j].name,member[j+1].name);
				strcpy(member[j+1].name,b);
				t=member[j].sum;
				member[j].sum=member[j+1].sum;
				member[j+1].sum=t;
				t=member[j].sno;
				member[j].sno=member[j+1].sno;
				member[j+1].sno=t;
			}
	for (i=0;i<n-1;i++)
	{
		if (member[i].sum==member[i+1].sum)
		{
			int len1,len2,minimum;
			len1=strlen(member[i].name);
			len2=strlen(member[i+1].name);
			if (len1>len2)
				minimum=len2;
			else
				minimum=len1;
			j=0;
			while (j<minimum)
			{
				if (member[i].name[j]==member[i+1].name[j])
					j++;
				else if (member[i].name[j]>member[i+1].name[j])
				{
					strcpy(b,member[i].name);
					strcpy(member[i].name,member[i+1].name);
					strcpy(member[i+1].name,b);
					t=member[i].sum;
					member[i].sum=member[i+1].sum;
					member[i+1].sum=t;
					t=member[i].sno;
					member[i].sno=member[i+1].sno;
					member[i+1].sno=t;
					break;
				}
				else
					break;
			}
			
		}
	}
	printf("[");
	for (i=0;i<n;i++)
	{
		printf("{name:%s,sum:%.0lf,sno:%d}",member[i].name,member[i].sum,member[i].sno);
		if (i!=n-1)
			printf(",\n");
	}
	printf("]");
	return 0;
}
